import React, { Component } from 'react'
import {
  BrowserRouter as Router,
  Switch,
  Route,
  Link,
  Redirect
} from 'react-router-dom'
import NewList from './newList'
import NotFound from './notFound'
import FoodsList from './foodslist'
import NewsDetail from './newsdetail'
import FoodsDetail from './FoodsDetail'

export default class index extends Component {
  render () {
    return (
      <Router>
        <div>
          <p>
            <Link to='/newslist'>新闻列表</Link>
          </p>
          <p>
            <Link to='/foodslist'>食品列表</Link>
          </p>
          <hr />
          <Switch>
            {/* <Route exact path='/' component={FoodsList} /> */}
            <Route path='/newslist'>
              <NewList />
            </Route>
            <Route path='/foodslist'>
              <FoodsList />
            </Route>
            <Redirect exact from='/' to='/foodslist'></Redirect>
            <Route path='/newsdetail' component={NewsDetail} />
            <Route path='/foodsdetail/:id/:name' component={FoodsDetail} />
            <Route to='*' component={NotFound}></Route>
          </Switch>
        </div>
      </Router>
    )
  }
}
